﻿/****************************** Module Header ******************************\
 * Module Name:  mxDialog.cs
 * Module Version:  1.0.0 (2013-1-23)
 * Copyright (c) AnyEB.Com (14507247@qq.com)
 * 
 * This class is used to extension winformcontrol instance's method.  It supplies 
 * public static extension methods to load data or get othor control.
 * 
 * This source is subject to the GPL License.
 * See http://www.gnu.org/licenses/gpl.html.
 * All other rights reserved.
 * 
 * THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, 
 * EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED 
 * WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
\***************************************************************************/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace UCL.Forms
{
    public static class mxDialog
    {
        /// <summary>
        /// 获取对话框文件名
        /// </summary>
        /// <param name="d"></param>
        /// <param name="filter"></param>
        /// <param name="docTypeName"></param>
        /// <returns></returns>
        public static string GetFileName(this FileDialog d, string filter = "Excel文件(*.xls) |*.xls |所有文件(*.*) |*.*", string docTypeName = "Excel")
        {
            d.Title = string.Format("{0}文件对话框", docTypeName);
            d.Filter = filter;
            d.FilterIndex = 1;
            if (DialogResult.OK != d.ShowDialog()) return string.Empty;
            return d.FileName;
        }
    }
}
